package com.linhh.mall.center.server.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.linhh.mall.center.api.BrandInfoService;
import com.linhh.mall.center.common.pojo.BrandInfo;
import com.linhh.mall.center.server.mappers.BrandInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * BrandInfoService接口实现类
 * @Author linhh
 * @Date 2022 11 01 22 50
 **/
@Slf4j
@Service
public class BrandInfoServiceImpl implements BrandInfoService {

    @Autowired
    private BrandInfoMapper brandInfoMapper;

    /**
     * 分页查询品牌信息
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public PageInfo<BrandInfo> getBrand(Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        Example example = new Example(BrandInfo.class);
        example.setOrderByClause("id desc");
        List<BrandInfo> allBrandList = brandInfoMapper.selectByExample(example);
        PageInfo<BrandInfo> pageInfo = new PageInfo<>(allBrandList);
        return pageInfo;
    }

    /**
     * 查询所有品牌信息
     * @return allBrandList
     */
    @Override
    public List<BrandInfo> getAllBrand() {
        List<BrandInfo> allBrandList = brandInfoMapper.selectAll();
        return allBrandList;
    }
}
